/**
  ******************************************************************************
  * @file           : sio_service.h
  * @brief          : Header for sio_service.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *	Created by Chen Lu in 20210527
  *
  ******************************************************************************
  */

#ifndef __SIO_SERVICE_H
#define __SIO_SERVICE_H

#include "main.h"

#define SIOSERVICE_OK		1
#define SIOSERVICE_ERROR	0

#define BUF_MAX_LENGTH		255

typedef struct{
	uint8_t len;
	uint8_t* p_data;
}DMARxTxService;

uint8_t USART1_RX_BUF[BUF_MAX_LENGTH];
uint8_t USART1_TX_BUF[BUF_MAX_LENGTH];

DMARxTxService USART1_RX;
DMARxTxService USART1_TX;

uint8_t USART2_RX_BUF[BUF_MAX_LENGTH];
uint8_t USART2_TX_BUF[BUF_MAX_LENGTH];

DMARxTxService USART2_RX;
DMARxTxService USART2_TX;


typedef struct {
	uint8_t rxbuf[127]; 		//receive buffer, used to store intact instruction
	uint8_t rxlen;
	uint8_t rxque[BUF_MAX_LENGTH];		//receive queue, used to store byte stream,
										//where we need to extra intact instruction
	uint8_t txlen;
	uint8_t txque[BUF_MAX_LENGTH];
}TiSioService;

TiSioService * sio_open(void);
uint8_t sio_close(TiSioService* sio);
uint8_t sio_recv(TiSioService* sio);
uint8_t sio_trans(TiSioService* sio, uint8_t* data);

#endif /* __SIO_SERVICE_H */
